/*** 
 * @_______________#########_______________________ 
 * @______________############_____________________ 
 * @______________#############____________________ 
 * @_____________##__###########___________________ 
 * @____________###__######_#####__________________ 
 * @____________###_#######___####_________________ 
 * @___________###__##########_####________________ 
 * @__________####__###########_####_______________ 
 * @________#####___###########__#####_____________ 
 * @_______######___###_########___#####___________ 
 * @_______#####___###___########___######_________ 
 * @______######___###__###########___######_______ 
 * @_____######___####_##############__######______ 
 * @____#######__#####################_#######_____ 
 * @____#######__##############################____ 
 * @___#######__######_#################_#######___ 
 * @___#######__######_######_#########___######___ 
 * @___#######____##__######___######_____######___ 
 * @___#######________######____#####_____#####____ 
 * @____######________#####_____#####_____####_____ 
 * @_____#####________####______#####_____###______ 
 * @______#####______;###________###______#________ 
 * @________##_______####________####______________ 
 * @
 * @Author: ipk518 18163976442@163.com
 * @Date: 2024-06-19 10:31:14
 * @LastEditors: ipk518 121206530@qq.com
 * @LastEditTime: 2025-09-06 10:49:02
 * @FilePath: /etws-sxk2307/inc/Hmc7044.h
 * @Description: 
 * @************佛祖保佑************
 * @Copyright (c) 2024 by etws@quyujiang, All Rights Reserved. 
 */

/*
 * @FilePath: /etws-sxk2307/inc/Hmc7044.h
 * @Description:  
 * @Author: ipk518 && 18163976442@163.com
 * @Date: 2024-04-15 11:50:09
 * @LastEditors: Do not edit
 * @LastEditTime: 2024-04-17 15:36:10
 * Copyright    : G AUTOMOBILE RESEARCH INSTITUTE CO.,LTD Copyright (c) 2024.
 */
#ifndef _HMC7044_
#define _HMC7044_

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

#define HMC7044_DEV_NAME "/dev/hmc7044"

struct __attribute__ ((__packed__)) Hmc7044
{
    uint8_t m_IdLsb;                //HMC7044 24位产品ID   (MSB:0x7a MIB:0x79 LSB:0x78) 
    uint8_t m_IdMid;            
    uint8_t m_IdMsb;            
    uint8_t m_Clock0Lose;           //HMC7044 时钟0丢失                    (0x7c) 1：丢失 0：正常
    uint8_t m_Clock1Lose;           //HMC7044 时钟1丢失                    (0x7c) 1：丢失 0：正常
    uint8_t m_Clock2Lose;           //HMC7044 时钟2丢失                    (0x7c) 1：丢失 0：正常
    uint8_t m_Clock3Lose;           //HMC7044 时钟3丢失                    (0x7c) 1：丢失 0：正常
    uint8_t m_Pll1Pll2LockStatus;   //HMC7044 PLL1和PLL2锁定检测           (0x7d) 1：锁定 0：失锁
    uint8_t m_ClockPhaseOut;        //HMC7044 时钟输出相位状态              (0x7d) 1：相位稳定 0：相位不稳定
    uint8_t m_SysrefSyncStatus;     //HMC7044 SYSREF同步状态               (0x7d) 1：不同步 0：同步
    uint8_t m_Registers7e;          //HMC7044 警报回读 查表 ：0x7e
    uint8_t m_Pll1ClkinValid;       //HMC7044 PLL1有效CLKIN0/CLKIN0输入    (0x82) 指示当前使用的CLKINx/CLKINx输入
    uint8_t m_Registers85;          //HMC7044 PLL1状态查询 查表：0x85
    uint8_t m_Registers8f;          //HMC7044 PLL2状态查询 查表：0x8f
};

extern bool hmc7044Open(const char* filename);
extern void hmc7044Close();
extern void hmc7044GetStatus( Hmc7044& st );
extern int hmc7044GetLock(void);
extern void hmc7044Reset(void);
extern void hmc7044SetReg(unsigned short reg,unsigned char dat);
extern int hmc7044ReadReg(unsigned short reg);
extern void setHmc7044WarnMask();

#endif